package com.skzh.web.controller.healthy;

import com.skzh.common.core.controller.BaseController;
import com.skzh.common.core.domain.AjaxResult;
import com.skzh.common.core.page.TableDataInfo;
import com.skzh.healthy.domain.DroneBattery;
import com.skzh.healthy.service.IDroneBatteryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/healthy/battery")
public class DeviceBatteryController extends BaseController {
    
    @Autowired
    private IDroneBatteryService batteryService;

    /**
     * 获取电池列表
     */
    @GetMapping("/list")
    public TableDataInfo list(DroneBattery battery) {
        startPage();
        return getDataTable(batteryService.selectBatteryList(battery));
    }

    /**
     * 获取在线电池列表
     */
    @GetMapping("/online")
    public TableDataInfo getOnlineBatteries(DroneBattery battery) {
        startPage();
        return getDataTable(batteryService.selectOnlineBatteries(battery));
    }

    /**
     * 获取告警电池列表
     */
    @GetMapping("/alarm")
    public AjaxResult getAlarmBatteries() {
        return success(batteryService.selectAlarmBatteries());
    }

    /**
     * 获取电池统计数据
     */
    @GetMapping("/stats")
    public AjaxResult getBatteryStats() {
        return success(batteryService.getBatteryStats());
    }

    /**
     * 报废电池
     */
    @PutMapping("/scrap/{id}")
    public AjaxResult scrapBattery(@PathVariable Long id) {
        return toAjax(batteryService.scrapBattery(id));
    }
}